import axios from 'axios'
export default {
  install: function (vue) {
    const instance = axios.create({
      baseURL: 'http://127.0.0.1:8888/api/private/v1/',
      timeout: 5000
    })
    instance.interceptors.response.use(res => {
      return res.data
    }, err => {
      console.log(err)
      return err
    })
    instance.interceptors.request.use(conf => {
      conf.headers.Authorization = window.sessionStorage.getItem('token')
      return conf
    })
    vue.prototype.$http = instance
  }
}
